﻿// -------------------------------------------------------------------------
//    @FileName         :    NFPhantomTroupePart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFPhantomTroupePart
//
// -------------------------------------------------------------------------

#include "NFPhantomTroupePart.h"

#include "proto_city.pb.h"
#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFPhantomTroupePart::NFPhantomTroupePart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFPhantomTroupePart::~NFPhantomTroupePart()
{
}

int NFPhantomTroupePart::CreateInit()
{
    return 0;
}
    
int NFPhantomTroupePart::ResumeInit()
{
    return 0;
}

int NFPhantomTroupePart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().activity_data().phantom_troupe_data());
    return 0;
}

int NFPhantomTroupePart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    pDbData->mutable_role_play_data()->mutable_activity_data()->mutable_phantom_troupe_data();
    return 0;
}

int NFPhantomTroupePart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_activity_data()->mutable_phantom_troupe_data());
    return 0;
}

int NFPhantomTroupePart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_phantom_troupe_data());
    return 0;
}

int NFPhantomTroupePart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    CHECK_NULL(0, pGCCityRoleInfo);
    for( int i = 0; i < m_stData.member_chase.level_id.size(); ++i )
    {
        pGCCityRoleInfo->mutable_troupe_info()->add_fin_level_id(m_stData.member_chase.level_id[i]);
    }

    for( int i = 0; i < m_stData.core_chase.level_id.size(); ++i )
    {
        pGCCityRoleInfo->mutable_troupe_info()->add_fin_level_id(m_stData.core_chase.level_id[i]);
    }

    for( int i = 0; i < m_stData.leader_chase.level_id.size(); ++i )
    {
        pGCCityRoleInfo->mutable_troupe_info()->add_fin_level_id(m_stData.leader_chase.level_id[i]);
    }
    return 0;
}
